/**  
 * @Title: IndexController.java
 * @Package com.limit.control.site
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-4-1 上午10:58:11
 * @version V1.0
 */ 
package com.limit.control.site;

import java.util.List;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;
import com.limit.model.AdSlide;
import com.limit.model.Admin;
import com.limit.model.Game;
import com.limit.model.Rank;

/** 
 * <br/>
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-4-1 上午10:58:11 
 * @version V1.0
 */

public class IndexSiteController extends BaseSiteController {
	
	private final int pageSize = 9;
	/** 
	 * 首页
	 */
	public void index() {
		this.setAttr("action", this);
		
		render("index.html");
		
	}
	
	public void more(){
		int rid = this.getParaToInt("rid", 0);
		if(rid <=0){
			this.render("404.html");
		}
		Rank rank = Rank.dao.findById(rid);
		if(null == rank){
			render("505.html");
		}
		this.setAttr("action", this);
		this.setAttr("rank",rank);
		this.setAttr("rid", rid);
		render("more.html");
	}
	
	/**
	 * 幻灯片
	 */
	public List<AdSlide> getAdSlides(){
		
		return AdSlide.dao.getSiteLists();
		
	}
	
	/**
	 * 排行榜列表
	 */
	public List<Rank> getRanks(){
		
		return Rank.dao.getViewList();
	}
	
	/**
	 * 排行榜下的游戏列表分页
	 */
	public Page<Game> getGames(long rank_id){
		return Game.dao.getGamesByRankId(rank_id,1,pageSize);
	}
	
	
	
}
